// pages/details/details.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    name:'',
    type_id:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options)
    this.setData({
      name:options.name,
      type_id:options.type_id
    })
  },

  onShow: function () {
    let access_token = wx.getStorageSync('access_token')
    wx.request({
      url: 'https://retire.wshoto.com/wx/newslist',
      data: {
        access_token: access_token,
        news_num: '-1',
        type_id: this.data.type_id
      },
      success: (res) => {
        console.log(res)
        if(res.data.code >= 500){
          app.getLogin().then(function(){
            console.log('二次登录。。。')
          })
        } else if (res.data.code == 1) {
          this.setData({
            newsList: res.data.list
          })
        }
      },
    })
  },

  toNewsDetail(e) {
    let news_id = e.currentTarget.dataset.id
    wx.navigateTo({
      url: '../news-details/news-details?news_id=' + news_id,
    })
  },
  
})